package org.bunny.vehicle.util;

import org.apache.commons.lang.StringUtils;

/**
 * 公用方法
 * 
 * @author Bunny
 * @version 2013-5-16 下午7:51:50
 * 
 */
public class Utils {

	// Empty checks
	// -----------------------------------------------------------------------
	/**
	 * <p>
	 * Checks if a CharSequence after
	 * {@link org.apache.commons.lang.StringUtils#stripToNull(java.lang.String)}
	 * is empty ("") or null.
	 * </p>
	 * 
	 * @param strs
	 *            the Strings to check, may be null
	 * @return {@code true} if the String is empty or null
	 */
	public static boolean isEmpty(String... strs) {
		for (String str : strs) {
			if (StringUtils.isEmpty(StringUtils.stripToNull(str))) {
				return true;
			}
		}
		return false;
	}

	public static boolean startsWithIgnoreCase(String string, String[] prefixs) {
		for (String str : prefixs) {
			if (StringUtils.startsWithIgnoreCase(string, str)) {
				return true;
			}
		}
		return false;
	}

	public static int stringToMoney(String moneyString) {
		int money = 0;
		try {
			if (StringUtils.indexOf(moneyString, '.') > 0) {
				float f = Float.parseFloat(moneyString);
				money = (int) (f * 100);
			} else {
				money = Integer.parseInt(moneyString);
				money *= 100;
			}
		} catch (Exception e) {
		}
		return money;
	}

	public static int parseInt(Object object) {
		try {
			return Integer.parseInt(object.toString());
		} catch (Exception e) {
			return 0;
		}
	}

}
